<?php
namespace app\model\admin;

use think\Db;

class Sale
{
    //获取商品列表
    public function get_sale_lists($where,$sort='',$paginate=10)
    {
        $result_lists = Db::name('sale')->where($where)->order($sort)->paginate($paginate);
        return $result_lists;
    }

    //商品详情
    public function sale_detail($page_id){
        $result = Db::name('sale')->where('id',$page_id)->find();
        return $result;
    }

    //商品添加
    public function add_sale($data){
        $status = Db::name('sale')->insert($data);
        return $status;
    }

    //商品修改
    public function update_sale($where,$data){
        $status = Db::name('sale')->where($where)->update($data);
        return $status;
    }

    //商品删除
    public function delete_sale($array_id){
        $sale_delete = Db::name('sale')->delete($array_id);
         return $sale_delete;
    }

    //添加商品关联联系
    public function add_sale_relation($data){
        $status = Db::name('sale_relation')->insert($data);
        return $status;
    }
    //查询商品关联联系
    public function select_sale_relation($where){
        $result_lists = Db::name('sale_relation')->where($where)->select();
        return $result_lists;
    }
    //商品关联关系删除
    public function del_sale_relation($array_id){
        $sale_delete = Db::name('sale_relation')->delete($array_id);
        return $sale_delete;
    }

}


